package com.life.view;

import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

public class LifeCanvasMouseAdapter extends AbstractAdapter implements MouseListener, MouseMotionListener
{

    LifeCanvas theCanvas = null;
    
    public LifeCanvasMouseAdapter(LifeCanvas canvas)
    {
	theCanvas = canvas;
	
	theCanvas.addMouseListener(this);
	theCanvas.addMouseMotionListener(this);
    }
    
    @Override
    public Object get()
    {
	// TODO Auto-generated method stub
	return null;
    }

    @Override
    public void set(Object data)
    {
	Point pointData = (Point)data;
	
	theCanvas.drawAlive(pointData.x,pointData.y);
	
    }

    @Override
    public void setEnabled(boolean value)
    {
	// TODO Auto-generated method stub
	
    }

    public void mouseClicked(MouseEvent e)
    {
	setChanged();
	notifyObservers(new Point(e.getX(),e.getY()));	
    }

    public void mouseEntered(MouseEvent e)
    {
	// TODO Auto-generated method stub
	
    }

    public void mouseExited(MouseEvent e)
    {
	// TODO Auto-generated method stub
	
    }

    public void mousePressed(MouseEvent e)
    {
	// TODO Auto-generated method stub
	
    }

    public void mouseReleased(MouseEvent e)
    {
	// TODO Auto-generated method stub
	
    }

    public void mouseDragged(MouseEvent e)
    {
	setChanged();
	notifyObservers(new Point(e.getX(),e.getY()));		
    }

    public void mouseMoved(MouseEvent e)
    {
	// TODO Auto-generated method stub
	
    }

}
